home *** CD-ROM | disk | FTP | other *** search
- on Funzioni_________________________
- end
-
- on InitSeparator
- global gSep
- if PC() then
- set gSep to "\"
- else
- set gSep to ":"
- end if
- end
-
- on PC
- if the machineType = 256 then
- return 1
- else
- return 0
- end if
- end
-
- on MAC
- if the machineType = 256 then
- return 0
- else
- return 1
- end if
- end
-
- on Sinistra stringa, Valore
- set lun to length(stringa)
- if Valore > lun then
- set Valore to lun
- end if
- if (Valore > 0) and (Valore <= lun) then
- return char 1 to Valore of stringa
- end if
- end
-
- on Centro stringa, inizio, fine
- set lun to length(stringa)
- if voidp(fine) then
- set fine to lun
- end if
- if (inizio > 0) and (fine <= lun) then
- return char inizio to fine of stringa
- end if
- end
-
- on Destra stringa, Valore
- set lun to length(stringa)
- if Valore > lun then
- set Valore to lun
- end if
- if (Valore >= 0) and (Valore <= lun) then
- set pos to lun - Valore + 1
- return char pos to lun of stringa
- end if
- end
-
- on BtnUp Bottone
- if Bottone <> EMPTY then
- set BottoneUp to "BtnUp" & char 6 to the length of Bottone of Bottone
- return BottoneUp
- end if
- end
-
- on BtnDw BottoneUp
- set BottoneDw to "BtnDw" & char 6 to the length of BottoneUp of BottoneUp
- return BottoneDw
- end
-
- on BtnRL BottoneUp
- set BottoneRL to "BtnRL" & char 6 to the length of BottoneUp of BottoneUp
- return BottoneRL
- end
-
- on BtnOf BottoneUp
- set BottoneOf to "BtnOf" & char 6 to the length of BottoneUp of BottoneUp
- return BottoneOf
- end
-
- on BtnName BottoneUp
- set Bottone to char 6 to the length of BottoneUp of BottoneUp
- return Bottone
- end
-
- on BtnICNName BottoneUp
- set Bottone to char 9 to the length of BottoneUp of BottoneUp
- return Bottone
- end
-
- on stageTop
- if the frontWindow = the stage then
- return 1
- end if
- return 0
- end
-
- on BtnChK mySprite, myRoll, myVariable
- global gRememberFolders, gBeepWhenDone, gSaveLogFile, gDestructive, gInvisible, gUnlockFile, gAskConfirm, gTempMultiAll, gRememberMultiList, gTempTimerAll, gTempTimerWhenNeeded, gTempRememberTimer, gTempDoAndQuit
- set myBtnUp to the name of member the member of sprite mySprite
- set myValue to value(the last char in myBtnUp)
- repeat while the stillDown
- if the rollOver = myRoll then
- set the member of sprite mySprite to BtnDw(myBtnUp)
- else
- set the member of sprite mySprite to myBtnUp
- end if
- updateStage()
- end repeat
- set the member of sprite mySprite to myBtnUp
- updateStage()
- if the rollOver = myRoll then
- set myscript to "set " & myVariable && "= not" && myVariable
- do(myscript)
- put value(myVariable) into char length(myBtnUp) of myBtnUp
- end if
- set the member of sprite mySprite to myBtnUp
- updateStage()
- end
-
- on BtnCHKDirection mySprite, myRoll
- global gOneDirection
- set myBtnUp to the name of member the member of sprite mySprite
- set myValue to value(the last char in myBtnUp)
- repeat while the stillDown
- if the rollOver = myRoll then
- set the member of sprite mySprite to BtnDw(myBtnUp)
- else
- set the member of sprite mySprite to myBtnUp
- end if
- updateStage()
- end repeat
- set the member of sprite mySprite to myBtnUp
- updateStage()
- if the rollOver = myRoll then
- set gOneDirection to not gOneDirection
- put char 1 of string(gOneDirection) into char length(myBtnUp) of myBtnUp
- set myPoint to point(the left of sprite 17 - 3, the top of sprite 17 - 3)
- if not gOneDirection then
- set the loc of sprite 50 to myPoint
- else
- set the locV of sprite 50 to -1000
- end if
- CheckOneDirection()
- end if
- set the member of sprite mySprite to myBtnUp
- updateStage()
- end
-
- on SetRadiogOnErrorDo
- global gOnErrorDo
- if voidp(gOnErrorDo) then
- set gOnErrorDo to 0
- end if
- if (gOnErrorDo <> 0) and (gOnErrorDo <> 1) and (gOnErrorDo <> 2) then
- set gOnErrorDo to 0
- end if
- set the member of sprite 28 to "BtnUpRadio0"
- set the member of sprite 30 to "BtnUpRadio0"
- set the member of sprite 32 to "BtnUpRadio0"
- case gOnErrorDo of
- 0:
- set mySprite to 28
- 1:
- set mySprite to 30
- 2:
- set mySprite to 32
- end case
- set the member of sprite mySprite to "BtnUpRadio1"
- end
-
- on OpenMyFile nomefile
- set file to new(xtra("fileio"))
- if objectp(file) then
- set err to openFile(file, nomefile, 1)
- if err = 0 then
- set myContent to readFile(file)
- closeFile(file)
- set file to 0
- return myContent
- else
- return 0
- end if
- end if
- return 0
- end
-
- on DisplaySaveMyFile nomefile
- set file to new(xtra("fileio"))
- if objectp(file) then
- set nomefile to displaySave(file, "Save the file as:", nomefile)
- set file to 0
- return nomefile
- end if
- set file to 0
- return EMPTY
- end
-
- on DisplayOpenMyFile type
- set file to new(xtra("fileio"))
- if objectp(file) then
- if length(type) = 4 then
- setFilterMask(file, type)
- end if
- set nomefile to displayOpen(file)
- set file to 0
- return nomefile
- end if
- set file to 0
- return EMPTY
- end
-
- on SaveTextFile nomefile, stringa, tipo, creat
- if voidp(tipo) then
- set tipo to "pref"
- end if
- if voidp(creat) then
- set creat to "ttxt"
- end if
- set file to new(xtra("fileio"))
- if objectp(file) then
- createFile(file, nomefile)
- openFile(file, nomefile, 0)
- writeString(file, stringa)
- setFinderInfo(file, tipo && creat)
- closeFile(file)
- set file to 0
- end if
- end
-
- on GetType myFile
- set myType to Sinistra(OSGetFileInfo(myFile), 4)
- return myType
- end
-
- on GetCreator myFile
- set myCreator to Destra(OSGetFileInfo(myFile), 4)
- return myCreator
- end
-
- on RimuoviLineFeed Testo
- set n to the number of lines in Testo
- set mytesto to EMPTY
- repeat with i = 1 to n - 1
- put line i of Testo & RETURN after mytesto
- end repeat
- put line n of Testo after mytesto
- return mytesto
- end
-
- on InitMonitor
- global gMyMonitor, gMyMonitorLeft, gMyMonitorTop, gMyWidthMonitor, gMyHeightMonitor, gCentroMonitorH, gCentroMonitorV, gMyStageWidth, gMyStageHeight
- set oldDelimiter to the itemDelimiter
- set the itemDelimiter to ","
- set x to getAt(the deskTopRectList, 1)
- set a to item 1 of string(x)
- set gMyMonitorLeft to value(char 6 to length(a) of a)
- set gMyMonitorTop to value(item 2 of string(x))
- set gMyWidthMonitor to value(item 3 of string(x)) - gMyMonitorLeft
- set gMyHeightMonitor to value(item 4 of string(x)) - gMyMonitorTop
- set gCentroMonitorH to gMyWidthMonitor / 2
- set gCentroMonitorV to gMyHeightMonitor / 2
- set gMyStageWidth to the stageRight - the stageLeft
- set gMyStageHeight to the stageBottom - the stageTop
- if (gMyWidthMonitor >= 832) and (gMyHeightMonitor >= 624) then
- set gMyMonitor to 17
- else
- if (gMyWidthMonitor >= 360) and (gMyHeightMonitor >= 360) then
- set gMyMonitor to 13
- else
- alert("It requires at least 360x360 monitor resolution.")
- quit()
- end if
- end if
- set the itemDelimiter to oldDelimiter
- end
-
- on InitColor
- global colorMark, ColorUnMark
- if PC() then
- set topdepth to 24
- else
- set topdepth to 32
- end if
- set the colorDepth to 16
- if the colorDepth <> 16 then
- set the colorDepth to topdepth
- if the colorDepth <> topdepth then
- set the colorDepth to 8
- if the colorDepth <> 8 then
- alert("Sono necessari almeno 256 colori.")
- quit()
- else
- alert("Questo monitor può visualizzare soltanto 256 colori dei 65.536 presenti. La qualità delle immagini potrebbe non essere buona.")
- set colorMark to 29
- set ColorUnMark to 255
- end if
- else
- if the machineType = 256 then
- set colorMark to 31
- set ColorUnMark to 255
- else
- set colorMark to 16724736
- set ColorUnMark to 0
- end if
- end if
- else
- if the machineType = 256 then
- set colorMark to 31
- set ColorUnMark to 255
- else
- set colorMark to 31936
- set ColorUnMark to 0
- end if
- end if
- end
-
- on InitXTRAs
- global gSep, gDirXTRAs, gLastBackUpDate
- if MAC() then
- set gSep to ":"
- set gDirXTRAs to the pathName & "PlugIn:"
- openXLib(gDirXTRAs & "OS")
- OSRegister(2014785220, 551689600)
- openXLib(gDirXTRAs & "K2")
- dosRegister(9888639)
- openXLib(gDirXTRAs & "Files")
- openXLib(gDirXTRAs & "WebF")
- openXLib(gDirXTRAs & "WebL")
- else
- set gDirXTRAs to the pathName & "XTRAsPC\"
- openXLib(gDirXTRAs & "OSUtil.x32")
- OSRegister(1978087018, 50958600)
- end if
- set gLastBackUpDate to [TodayYear(1), TodayMonth(1), TodayDay(1)]
- end
-
- on InitFolders
- global gSep, gThisVersion, gDirPref, gDirDialog, gNomeFilePref, gDirLog, gDirXTRAs
- if MAC() then
- set gDirPref to OSSpecialPath("pref") & ":"
- else
- set gDirPref to "C:\"
- end if
- set gNomeFilePref to "FoldersSync" && gThisVersion && "Prefs"
- set gDirDialog to gDirXTRAs
- set gDirLog to the pathName & "Log Files" & gSep
- end
-
- on ExtractFileNameFromPath myPath
- global gSep
- set oldDelimiter to the itemDelimiter
- set the itemDelimiter to gSep
- if the last char in myPath = gSep then
- delete char -30000 of myPath
- end if
- set myReturn to the last item in myPath
- set the itemDelimiter to oldDelimiter
- return myReturn
- end
-
- on ExtractParentFolder myPath
- global gSep
- set oldDelimiter to the itemDelimiter
- set the itemDelimiter to gSep
- if the last char in myPath = gSep then
- delete char -30000 of myPath
- end if
- set k to the number of items in myPath - 1
- set myReturn to item 1 to k of myPath & gSep
- set the itemDelimiter to oldDelimiter
- return myReturn
- end
-
- on ExtractParentFolderName myPath
- global gSep
- set oldDelimiter to the itemDelimiter
- set the itemDelimiter to gSep
- set k to the number of items in myPath - 1
- set myReturn to item k of myPath & gSep
- set the itemDelimiter to oldDelimiter
- return myReturn
- end
-
- on SourceToDestFolder sourceFold
- global gSourceFolder, gDestFolder
- set s to the number of items in gSourceFolder - 1
- set SemiDestFold to item 1 to the number of items in gDestFolder - 1 of gDestFolder
- set destFold to sourceFold
- put SemiDestFold into item 1 to s of destFold
- return destFold
- end
-
- on DestToSourceFolder destFold
- global gSourceFolder, gDestFolder
- set s to the number of items in gDestFolder - 1
- set SemiSourceFold to item 1 to the number of items in gSourceFolder - 1 of gSourceFolder
- set sourceFold to destFold
- put SemiSourceFold into item 1 to s of sourceFold
- return sourceFold
- end
-
- on SaveLogFile
- global gDirLog, gBigTextLog, gOneDirection, gMyLogFilePath, gLogPathList
- if OSIsDirectory(gDirLog) = 0 then
- set parID to ExtractParentFolder(gDirLog)
- set fileName to ExtractFileNameFromPath(gDirLog)
- set newPathName to gDirLog
- set k to 0
- repeat while OSIsDirectory(newPathName) = 0
- set k to k + 1
- set lun to 30 - length(string(k))
- set newPathName to parID & Sinistra(fileName, lun) & "." & string(k)
- end repeat
- set NewName to ExtractFileNameFromPath(newPathName)
- set err to OSRename(gDirLog, NewName)
- if err then
- AlertBox("Error renaming file" && QUOTE & newPathName & QUOTE & ".")
- exit
- end if
- end if
- if OSIsDirectory(gDirLog) = -43 then
- set err to OSCreateDir(the pathName, "Log Files")
- if err then
- AlertBox("Error creating Folder" && QUOTE & "Log" & QUOTE & ".")
- exit
- end if
- end if
- if gOneDirection <> 1 then
- set myPrefix to "Sync_"
- else
- set myPrefix to "Bckp_"
- end if
- set myFileName to myPrefix & GetDateAndTime()
- set gMyLogFilePath to PuntoDuplicati(gDirLog & myFileName)
- SaveTextFile(gMyLogFilePath, gBigTextLog, "TEXT")
- append(gLogPathList, gMyLogFilePath)
- end
-
- on PuntoDuplicati sourceFile
- set parID to ExtractParentFolder(sourceFile)
- set fileName to ExtractFileNameFromPath(sourceFile)
- set newPathName to sourceFile
- set k to 0
- repeat while (OSIsDirectory(newPathName) = 0) or (OSIsDirectory(newPathName) = 1)
- set k to k + 1
- set lun to 30 - length(string(k))
- set newPathName to parID & Sinistra(fileName, lun) & "." & string(k)
- end repeat
- return newPathName
- end
-
- on ScriviFilePreference
- global gDirPref, gNomeFilePref, gRememberFolders, gTopFolder, gBottomFolder, gRememberMultiList, gMultiAll, gMultiOnList, gMultiPathSourceList, gMultiPathDestList, gMaxMulti, gRememberTimer, gTimerAll, gTimerOnList, gTimerHourList, gTimerDayList, gMaxTimer, gTimerBy, gAppliedHourList, gAppliedDayList, gDaysInterval, gHoursInterval, gMinutesInterval, gStartMonth, gStartDay, gStartYear, gStartHour, gStartMinute, gStartInterval, gTheInterval
- if not gRememberFolders then
- set gTopFolder to EMPTY
- set gBottomFolder to EMPTY
- end if
- if not gRememberMultiList then
- set gMultiAll to 0
- repeat with i = 1 to gMaxMulti
- setAt(gMultiOnList, i, 1)
- setAt(gMultiPathSourceList, i, 0)
- setAt(gMultiPathDestList, i, 0)
- end repeat
- end if
- if not gRememberTimer then
- set gTimerAll to 0
- set gTimerBy to 1
- set gAppliedHourList to []
- set gAppliedDayList to []
- repeat with i = 1 to gMaxTimer
- setAt(gTimerOnList, i, 1)
- setAt(gTimerHourList, i, " ")
- setAt(gTimerDayList, i, -1)
- end repeat
- set gDaysInterval to -1
- set gHoursInterval to -1
- set gMinutesInterval to -1
- set gStartMonth to -1
- set gStartDay to -1
- set gStartYear to -1
- set gStartHour to -1
- set gStartMinute to -1
- set gStartInterval to -1
- set gTheInterval to -1
- end if
- set myPreferenze to getPreferenze()
- if OSIsDirectory(gDirPref & gNomeFilePref) = 0 then
- OSDelete(gDirPref & gNomeFilePref)
- end if
- SaveTextFile(gDirPref & gNomeFilePref, myPreferenze)
- end
-
- on getPreferenze
- global gTopFolder, gBottomFolder, gBeepWhenDone, gSaveLogFile, gRememberFolders, gOneDirection, gDestructive, gInvisible, gUnlockFile, gOnErrorDo, gAskConfirm, gFilterAll, gFilterCopySkip, gFilterOn, gFilterType, gFilterCreat, gFilterOper, gFilterDate, gLastBackUpDate, gMultiAll, gRememberMultiList, gMultiOnList, gMultiPathSourceList, gMultiPathDestList, gTimerAll, gRememberTimer, gTimerBy, gTimerOnList, gTimerHourList, gTimerDayList, gAppliedHourList, gAppliedDayList, gDoAndQuit, gDaysInterval, gHoursInterval, gMinutesInterval, gStartMonth, gStartDay, gStartYear, gStartHour, gStartMinute, gStartInterval, gTheInterval, gRectReport, gRectWindDate, gRectWindTimerHour
- set mystringa to "--SETTAGGI PREFERENZE" & RETURN & "global gTopFolder, gBottomFolder" & RETURN & "global gBeepWhenDone, gSaveLogFile, gRememberFolders" & RETURN & "global gOneDirection, gDestructive, gInvisible" & RETURN & "global gUnlockFile, gOnErrorDo, gAskConfirm" & RETURN & RETURN & "global gFilterAll, gFilterCopySkip" & RETURN & "global gFilterOn, gFilterType, gFilterCreat, gFilterOper, gFilterDate, gLastBackUpDate" & RETURN & RETURN & "global gMultiAll, gRememberMultiList, gMultiOnList, gMultiPathSourceList, gMultiPathDestList" & RETURN & RETURN & "global gTimerAll, gRememberTimer, gTimerBy" & RETURN & RETURN & "global gTimerOnList, gTimerHourList, gTimerDayList" & RETURN & "global gAppliedHourList, gAppliedDayList, gDoAndQuit" & RETURN & RETURN & "global gDaysInterval, gHoursInterval, gMinutesInterval" & RETURN & "global gStartMonth, gStartDay, gStartYear, gStartHour, gStartMinute" & RETURN & "global gStartInterval, gTheInterval" & RETURN & RETURN & "global gRectReport, gRectWindDate, gRectWindTimerHour" & RETURN & RETURN & RETURN & "set gTopFolder=" & SostApici(gTopFolder) & RETURN & "set gBottomFolder=" & SostApici(gBottomFolder) & RETURN & "set gRememberFolders=" & gRememberFolders & RETURN & "set gOneDirection=" & gOneDirection & RETURN & "set gDestructive=" & gDestructive & RETURN & "set gBeepWhenDone=" & gBeepWhenDone & RETURN & "set gSaveLogFile=" & gSaveLogFile & RETURN & "set gInvisible=" & gInvisible & RETURN & "set gUnlockFile=" & gUnlockFile & RETURN & "set gOnErrorDo=" & gOnErrorDo & RETURN & "set gAskConfirm=" & gAskConfirm & RETURN & "set gFilterAll=" & gFilterAll & RETURN & "set gFilterCopySkip=" & gFilterCopySkip & RETURN & "set gFilterOn=" & gFilterOn & RETURN & "set gFilterType=value(" & SostApici(string(gFilterType)) & ")" & RETURN & "set gFilterCreat=value(" & SostApici(string(gFilterCreat)) & ")" & RETURN & "set gFilterOper=value(" & SostApici(string(gFilterOper)) & ")" & RETURN & "set gFilterDate=value(" & SostApici(string(gFilterDate)) & ")" & RETURN & "set gLastBackUpDate=value(" & SostApici(string(gLastBackUpDate)) & ")" & RETURN & "set gRectReport=" & gRectReport & RETURN & "set gRectWindDate=" & gRectWindDate & RETURN & "set gRectWindTimerHour=" & gRectWindTimerHour & RETURN & RETURN & "set gMultiAll=" & gMultiAll & RETURN & "set gRememberMultiList=" & gRememberMultiList & RETURN & "set gMultiOnList=" & gMultiOnList & RETURN & "set gMultiPathSourceList=value(" & SostApici(string(gMultiPathSourceList)) & ")" & RETURN & "set gMultiPathDestList=value(" & SostApici(string(gMultiPathDestList)) & ")" & RETURN & "ImpostagSourceDestFolders" & RETURN & RETURN & "set gTimerAll=" & gTimerAll & RETURN & "set gRememberTimer=" & gRememberTimer & RETURN & "set gTimerBy=" & gTimerBy & RETURN & RETURN & "set gTimerOnList=" & gTimerOnList & RETURN & "set gTimerHourList=value(" & SostApici(string(gTimerHourList)) & ")" & RETURN & "set gTimerDayList=" & gTimerDayList & RETURN & "set gAppliedHourList=value(" & SostApici(string(gAppliedHourList)) & ")" & RETURN & "set gAppliedDayList=" & gAppliedDayList & RETURN & "set gDoAndQuit=" & gDoAndQuit & RETURN & "PrepareTimerToDoList()" & RETURN & RETURN & "set gDaysInterval=" & gDaysInterval & RETURN & "set gHoursInterval=" & gHoursInterval & RETURN & "set gMinutesInterval=" & gMinutesInterval & RETURN & "set gStartMonth=" & gStartMonth & RETURN & "set gStartDay=" & gStartDay & RETURN & "set gStartYear=" & gStartYear & RETURN & "set gStartHour=" & gStartHour & RETURN & "set gStartMinute=" & gStartMinute & RETURN & "set gStartInterval=" & gStartInterval & RETURN & "set gTheInterval=" & gTheInterval & RETURN
- return mystringa
- end
-
- on SostApici Testo
- set Lungh to length(Testo)
- set retTesto to QUOTE
- repeat with i = 1 to Lungh
- set myChar to char i of Testo
- if myChar = QUOTE then
- put QUOTE & ""E&" & QUOTE after retTesto
- next repeat
- end if
- put myChar after retTesto
- end repeat
- put QUOTE after retTesto
- return retTesto
- end
-
- on LeggiPreferenze
- global gDirPref, gNomeFilePref
- if OSIsDirectory(gDirPref & gNomeFilePref) = 0 then
- set file to new(xtra("fileio"))
- if objectp(file) then
- openFile(file, gDirPref & gNomeFilePref, 0)
- set myscript to readFile(file)
- if PC() then
- set myscript to RimuoviLineFeed(myscript)
- end if
- closeFile(file)
- set file to 0
- do(myscript)
- end if
- end if
- end
-
- on AccorciaNome path, maxlun
- global gSep
- if voidp(maxlun) then
- set maxlun to 49
- end if
- set lun to length(path)
- if lun <= maxlun then
- if the last char in path = gSep then
- delete char -30000 of path
- end if
- return path
- return Sinistra(path, lun)
- end if
- set maxLunP to 11
- set maxLunF to maxlun - maxLunP
- set myFolder to ExtractFileNameFromPath(path)
- set myTempLunF to length(myFolder)
- if myTempLunF > maxLunF then
- set myFolder to Sinistra(myFolder, maxLunF - 3) & "..."
- end if
- set maxLunF to length(myFolder)
- set maxLunP to maxlun - maxLunF
- set myPar to ExtractParentFolder(path)
- set myTempLunP to length(myPar)
- if myTempLunP > maxLunP then
- set myPar to Sinistra(myPar, maxLunP - 3) & "..."
- end if
- return myPar & myFolder
- end
-
- on ConfrontaRecenteFile sourceF, destF
- set a to OSFileModify(sourceF)
- set b to OSFileModify(destF)
- if a = b then
- return 0
- end if
- if (a = EMPTY) or (b = EMPTY) or (a < 0) or (b < 0) then
- return 1
- end if
- set oldDelimiter to the itemDelimiter
- set the itemDelimiter to ","
- set myDateA to item 1 of a
- set myTimeA to item 2 of a
- set myDateB to item 1 of b
- set myTimeB to item 2 of b
- set the itemDelimiter to "/"
- set myYearA to value(item 1 of myDateA)
- set myMonthA to value(item 2 of myDateA)
- set myDayA to value(item 3 of myDateA)
- set myYearB to value(item 1 of myDateB)
- set myMonthB to value(item 2 of myDateB)
- set myDayB to value(item 3 of myDateB)
- set the itemDelimiter to oldDelimiter
- if myYearA > myYearB then
- return 1
- end if
- if myYearB > myYearA then
- return 2
- end if
- if myMonthA > myMonthB then
- return 1
- end if
- if myMonthB > myMonthA then
- return 2
- end if
- if myDayA > myDayB then
- return 1
- end if
- if myDayB > myDayA then
- return 2
- end if
- set the itemDelimiter to ":"
- set myHourA to value(item 1 of myTimeA)
- set myMinuA to value(item 2 of myTimeA)
- set mySecoA to value(item 3 of myTimeA)
- set myHourB to value(item 1 of myTimeB)
- set myMinuB to value(item 2 of myTimeB)
- set mySecoB to value(item 3 of myTimeB)
- set the itemDelimiter to oldDelimiter
- if myHourA > myHourB then
- return 1
- end if
- if myHourB > myHourA then
- return 2
- end if
- if myMinuA > myMinuB then
- return 1
- end if
- if myMinuB > myMinuA then
- return 2
- end if
- if mySecoA > mySecoB then
- return 1
- end if
- if mySecoB > mySecoA then
- return 2
- end if
- end
-
- on CheckSyncButton
- global gSourceFolder, gDestFolder, gNero, gGrigio, gSyncPermitted, gOneDirection
- set gSyncPermitted to (gDestFolder <> EMPTY) and (gSourceFolder <> EMPTY)
- if gSyncPermitted then
- set the foreColor of member "P4" to gNero
- else
- set the foreColor of member "P4" to gGrigio
- end if
- set the enabled of menuItem 3 of menu "File" to gSyncPermitted
- end
-
- on CheckOneDirection
- global gOneDirection
- if gOneDirection then
- put "BackUp" into field "P4"
- set the name of menuItem 3 of menu "File" to "BackUp"
- else
- put "Synchronize" into field "P4"
- set the name of menuItem 3 of menu "File" to "Synchronize"
- end if
- set the picture of member "ICNBack" to the picture of member ("ICNBack" & string(gOneDirection))
- updateStage()
- end
-
- on NoSelectedFolders
- global gSourceFolder, gDestFolder
- set err to 0
- if (gSourceFolder = EMPTY) or voidp(gSourceFolder) then
- set err to 1
- else
- if (gDestFolder = EMPTY) or voidp(gDestFolder) then
- set err to 3
- end if
- end if
- if err = 0 then
- return err
- end if
- case err of
- 1:
- set ALRTmessaggio to "Choose the 1st Folder by clicking on the Top Folder Icon."
- 3:
- set ALRTmessaggio to "Choose the 2nd Folder by clicking on the Bottom Folder Icon."
- end case
- AlertBox(ALRTmessaggio)
- return err
- end
-
- on NoValidFolders
- global gSourceFolder, gDestFolder, gStopTimerAll, gOnErrorDo, gSaveLogFile, gBigTextLog, gShortTextLog
- set err to 0
- if OSIsDirectory(gSourceFolder) <> 1 then
- set err to 2
- else
- if OSIsDirectory(gDestFolder) <> 1 then
- set err to 4
- end if
- end if
- if err = 0 then
- return err
- end if
- case err of
- 2:
- set ALRTmessaggio to "Cannot found the 1st Folder" && QUOTE & AccorciaNome(gSourceFolder) & QUOTE & "."
- set LOGmessaggio to ALRTmessaggio & RETURN & myOperation() & " stopped."
- 4:
- set ALRTmessaggio to "Cannot found the 2nd Folder" && QUOTE & AccorciaNome(gDestFolder) & QUOTE & "."
- set LOGmessaggio to ALRTmessaggio & RETURN & myOperation() & " stopped."
- end case
- if gOnErrorDo = 0 then
- AlertBox(ALRTmessaggio & MsgTimer())
- end if
- put LOGmessaggio after gBigTextLog
- if gSaveLogFile then
- SaveLogFile()
- end if
- set gBigTextLog to EMPTY
- return err
- end
-
- on GetDateAndTime
- set myDT to OSConstDate()
- set Lungh to length(myDT)
- repeat with i = 1 to Lungh
- if (char i of myDT = "/") or (char i of myDT = ",") or (char i of myDT = ":") then
- put "_" into char i of myDT
- end if
- end repeat
- return myDT
- end
-
- on GetModifDate sourceF
- set a to OSFileModify(sourceF)
- set oldDelimiter to the itemDelimiter
- set the itemDelimiter to ","
- set myDateA to item 1 of a
- set the itemDelimiter to "/"
- set myYearA to value(item 1 of myDateA)
- set myMonthA to MeseCorto(value(item 2 of myDateA))
- set myDayA to value(item 3 of myDateA)
- set the itemDelimiter to oldDelimiter
- return string(myDayA) && myMonthA && string(myYearA)
- end
-
- on TodayYear stringa
- set x to Sinistra(OSConstDate(), 4)
- if stringa then
- return x
- end if
- return value(x)
- end
-
- on TodayMonth stringa
- set x to Centro(OSConstDate(), 6, 7)
- if stringa then
- return x
- end if
- return value(x)
- end
-
- on TodayDay stringa
- set x to Centro(OSConstDate(), 9, 10)
- if stringa then
- return x
- end if
- return value(x)
- end
-
- on NowHour stringa
- set x to Centro(OSConstDate(), 12, 13)
- if stringa then
- return x
- end if
- return value(x)
- end
-
- on NowMinute stringa
- set x to Centro(OSConstDate(), 15, 16)
- if stringa then
- return x
- end if
- return value(x)
- end
-
- on MeseCorto numMese
- case numMese of
- 1:
- return "jen"
- 2:
- return "feb"
- 3:
- return "mar"
- 4:
- return "apr"
- 5:
- return "may"
- 6:
- return "jun"
- 7:
- return "jul"
- 8:
- return "aug"
- 9:
- return "gSep"
- 10:
- return "oct"
- 11:
- return "nov"
- 12:
- return "dec"
- end case
- return " "
- end
-
- on MeseNum mese
- case mese of
- "jen":
- return "01"
- "feb":
- return "02"
- "mar":
- return "03"
- "apr":
- return "04"
- "may":
- return "05"
- "jun":
- return "06"
- "jul":
- return "07"
- "aug":
- return "08"
- "gSep":
- return "09"
- "oct":
- return 10
- "nov":
- return 11
- "dec":
- return 12
- end case
- return "00"
- end
-
- on SecondsInMinute myTime
- set ore to myTime / 3600
- set minuti to myTime / 60 mod 60
- set secondi to myTime mod 60
- if ore < 10 then
- set ore to "0" & ore & ":"
- end if
- if minuti < 10 then
- set minuti to "0" & minuti
- end if
- if secondi < 10 then
- set secondi to "0" & secondi
- end if
- return ore & minuti & ":" & secondi
- end
-
- on GetUniquePathNameInFolder destFold
- global gSep
- set parID to ExtractParentFolder(destFold)
- set fileName to ExtractFileNameFromPath(destFold)
- set newPathName to parID & fileName
- set k to 0
- repeat while (OSIsDirectory(newPathName) >= 0) or (OSIsDirectory(DestToSourceFolder(newPathName)) >= 0)
- set k to k + 1
- set lun to 30 - length(string(k))
- set newPathName to parID & Sinistra(fileName, lun) & "." & string(k)
- end repeat
- return newPathName
- end
-
- on SetHeaderLogFile
- global gMultiAll, gMultiXSource, gIterMulti, gOneDirection, gFilterAll, gFilterTextLog, gNumFilters, gSourceFolder, gDestFolder, gBigTextLog, gShortTextLog, gBeepWhenDone, gSaveLogFile, gRememberFolders, gInvisible, gUnlockFile, gDestructive, gOnErrorDo, gAskConfirm
- set gBigTextLog to EMPTY
- if gMultiAll then
- set TotMulti to count(gMultiXSource)
- set StringaMulti to "Multiple (" & string(gIterMulti) & " of " & TotMulti & ") "
- else
- set StringaMulti to EMPTY
- end if
- if gOneDirection then
- set myOperation to "BackUp"
- else
- set myOperation to "Synchronization"
- end if
- set myStrFiltri to EMPTY
- if gFilterAll and (gNumFilters > 0) then
- set StringaFiltri to "(with" && gNumFilters && "filters) "
- else
- set StringaFiltri to EMPTY
- end if
- set gBigTextLog to StringaMulti & myOperation && StringaFiltri & "from:" & RETURN & gSourceFolder && "to:" & RETURN & gDestFolder & RETURN & RETURN
- put "Preferences: " & RETURN & "If an error occurred:" && StopSkip(gOnErrorDo) & RETURN & "Beep When Done:" && YesNot(gBeepWhenDone) & RETURN & "Save Log File:" && YesNot(gSaveLogFile) & RETURN & "Remember Folders:" && YesNot(gRememberFolders) & RETURN & "One Direction Only:" && YesNot(gOneDirection) & RETURN & "Exact BackUp:" && YesNot(gDestructive) & RETURN & "Invisible Items:" && YesNot(gInvisible) & RETURN & "Unlock locked files:" && YesNot(gUnlockFile) & RETURN & "Ask Confirm:" && YesNot(gAskConfirm) & RETURN & "--" & RETURN after gBigTextLog
- if gFilterAll and (gNumFilters > 0) then
- put gFilterTextLog after gBigTextLog
- end if
- put "Start at:" && the long date && "-" && the long time & RETURN after gBigTextLog
- set gShortTextLog to gBigTextLog
- end
-
- on YesNot Valore
- if Valore then
- return "Yes"
- else
- return "No"
- end if
- end
-
- on StopSkip Valore
- if Valore then
- return "Skip"
- else
- return "Stop"
- end if
- end
-
- on myOperation
- global gOneDirection, gIterMulti
- if gOneDirection then
- if (gIterMulti - 1) > 1 then
- return "BackUps"
- else
- return "BackUp"
- end if
- else
- if (gIterMulti - 1) > 1 then
- return "Synchronizations"
- else
- return "Synchronization"
- end if
- end if
- end
-
- on MyOperationBtn
- global gOneDirection
- if gOneDirection then
- return "BackUp"
- else
- return "Synchronize"
- end if
- end
-